<?php
    header('content-type:application/json');
    $con=mysqli_connect("localhost" ,"root","root");
    if (mysqli_connect_errno($con)) { 
        echo "连接 MySQL 失败: " . mysqli_connect_error(); 
    }
    mysqli_select_db($con, "news");
    $sql="select * from article";
    $result=mysqli_query($con, $sql);
    $json = [];
    while($obj=mysqli_fetch_object($result)){
        $json[] = $obj;
    }
    mysqli_free_result($result);
    mysqli_close($con);
    exit(json_encode($json));
?>